package org.linlinjava.litemall.admin.web;

import org.linlinjava.litemall.admin.service.AdminBookReviewService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/admin/bookReview")
public class AdminBookReviewController {
    @Autowired
    private AdminBookReviewService bookReviewService;

    /**
     * 根据不同状态（0：全部，1：待审核::2：已通过，3：未通过）查询list
     * @param status
     * @param page
     * @param limit
     * @param sort
     * @param order
     * @return
     */
    @GetMapping("/list")
    public Object list(@RequestParam Integer status,
                       @RequestParam(required = false,defaultValue = "1") Integer page,
                       @RequestParam(required = false,defaultValue = "10") Integer limit,
                       @RequestParam(required = false,defaultValue = "add_time") String sort,
                       @RequestParam(required = false,defaultValue = "desc") String order) {
        return ResponseUtil.okList(bookReviewService.queryList(status, page, limit, sort, order));
    }

    /**
     * 审核书评 通过
     * @param bookReviewId
     * @return
     */
    @PostMapping("/pass")
    public Object pass(@RequestBody Integer bookReviewId) {
        return bookReviewService.pass(bookReviewId);
    }

    /**
     * 审核书评 不通过
     * @param bookReviewId
     * @return
     */
    @PostMapping("/fail")
    public Object fail(@RequestBody Integer bookReviewId) {
        return bookReviewService.fail(bookReviewId);
    }
}
